#include <linux/spinlock.h>
#include <linux/skbuff.h>
#include <linux/of.h>
-#include <linux/of_platform.h>
#include <linux/of_gpio.h>
-#include <linux/rtl8366.h>
#include <linux/version.h>
#include <linux/of_mdio.h>
+#include <linux/platform_device.h>
#ifdef CONFIG_RTL8366_SMI_DEBUG_FS
#include <linux/debugfs.h>
static int rtl8366_smi_mii_init(struct rtl8366_smi *smi)
{
int ret;
-
-#ifdef CONFIG_OF
struct device_node *np = NULL;
- np = of_get_child_by_name(smi->parent->of_node, "mdio-bus");
-#endif
-
smi->mii_bus = mdiobus_alloc();
if (smi->mii_bus == NULL) {
ret = -ENOMEM;
smi->mii_bus->parent = smi->parent;
smi->mii_bus->phy_mask = ~(0x1f);
-#ifdef CONFIG_OF
+ np = of_get_child_by_name(smi->parent->of_node, "mdio-bus");
if (np)
ret = of_mdiobus_register(smi->mii_bus, np);
else
-#endif
ret = mdiobus_register(smi->mii_bus);
if (ret)
}
}
-enum rtl8366_type rtl8366_smi_detect(struct rtl8366_platform_data *pdata)
-{
- static struct rtl8366_smi smi;
- enum rtl8366_type type = RTL8366_TYPE_UNKNOWN;
- u32 reg = 0;
-
- memset(&smi, 0, sizeof(smi));
- smi.gpio_sda = pdata->gpio_sda;
- smi.gpio_sck = pdata->gpio_sck;
- smi.clk_delay = 10;
- smi.cmd_read = 0xa9;
- smi.cmd_write = 0xa8;
-
- if (__rtl8366_smi_init(&smi, "rtl8366"))
- goto out;
-
- if (rtl8366_smi_read_reg(&smi, 0x5c, ®))
- goto cleanup;
-
- switch(reg) {
- case 0x6027:
- printk("Found an RTL8366S switch\n");
- type = RTL8366_TYPE_S;
- break;
- case 0x5937:
- printk("Found an RTL8366RB switch\n");
- type = RTL8366_TYPE_RB;
- break;
- default:
- printk("Found an Unknown RTL8366 switch (id=0x%04x)\n", reg);
- break;
- }
-
-cleanup:
- __rtl8366_smi_cleanup(&smi);
-out:
- return type;
-}
-
int rtl8366_smi_init(struct rtl8366_smi *smi)
{
int err;
}
EXPORT_SYMBOL_GPL(rtl8366_smi_cleanup);
-#ifdef CONFIG_OF
static void rtl8366_smi_reset(struct rtl8366_smi *smi, bool active)
{
if (active)
return 0;
}
-#else
-static inline int rtl8366_smi_probe_of(struct platform_device *pdev, struct rtl8366_smi *smi)
-{
- return -ENODEV;
-}
-#endif
-
-static int rtl8366_smi_probe_plat(struct platform_device *pdev, struct rtl8366_smi *smi)
-{
- struct rtl8366_platform_data *pdata = pdev->dev.platform_data;
-
- if (!pdev->dev.platform_data) {
- dev_err(&pdev->dev, "no platform data specified\n");
- return -EINVAL;
- }
-
- smi->gpio_sda = pdata->gpio_sda;
- smi->gpio_sck = pdata->gpio_sck;
- smi->hw_reset = pdata->hw_reset;
- smi->phy_id = MDC_REALTEK_PHY_ADDR;
-
- return 0;
-}
-
struct rtl8366_smi *rtl8366_smi_probe(struct platform_device *pdev)
{
if (!smi)
return NULL;
- if (pdev->dev.of_node)
- err = rtl8366_smi_probe_of(pdev, smi);
- else
- err = rtl8366_smi_probe_plat(pdev, smi);
-
+ err = rtl8366_smi_probe_of(pdev, smi);
if (err)
goto free_smi;
#include <linux/init.h>
#include <linux/device.h>
#include <linux/of.h>
-#include <linux/of_platform.h>
+#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/skbuff.h>
-#include <linux/rtl8366.h>
#include "rtl8366_smi.h"
#define RTL8366RB_DRIVER_DESC "Realtek RTL8366RB ethernet switch driver"
#define RTL8366RB_DRIVER_VER "0.2.4"
+#define RTL8366RB_DRIVER_NAME "rtl8366rb"
#define RTL8366RB_PHY_NO_MAX 4
#define RTL8366RB_PHY_PAGE_MAX 7
static int rtl8366rb_setup(struct rtl8366_smi *smi)
{
int err;
-#ifdef CONFIG_OF
unsigned i;
- struct device_node *np;
unsigned num_initvals;
const __be32 *paddr;
-
- np = smi->parent->of_node;
+ struct device_node *np = smi->parent->of_node;
paddr = of_get_property(np, "realtek,initvals", &num_initvals);
if (paddr) {
REG_WR(smi, reg, val);
}
}
-#endif
/* set maximum packet length to 1536 bytes */
REG_RMW(smi, RTL8366RB_SGCR, RTL8366RB_SGCR_MAX_LENGTH_MASK,
}
}
-#ifdef CONFIG_OF
static const struct of_device_id rtl8366rb_match[] = {
{ .compatible = "realtek,rtl8366rb" },
{},
};
MODULE_DEVICE_TABLE(of, rtl8366rb_match);
-#endif
static struct platform_driver rtl8366rb_driver = {
.driver = {
.name = RTL8366RB_DRIVER_NAME,
- .of_match_table = of_match_ptr(rtl8366rb_match),
+ .of_match_table = rtl8366rb_match,
},
.probe = rtl8366rb_probe,
.remove_new = rtl8366rb_remove,
#include <linux/init.h>
#include <linux/device.h>
#include <linux/of.h>
-#include <linux/of_platform.h>
+#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/skbuff.h>
-#include <linux/rtl8366.h>
#include "rtl8366_smi.h"
#define RTL8366S_DRIVER_DESC "Realtek RTL8366S ethernet switch driver"
#define RTL8366S_DRIVER_VER "0.2.2"
+#define RTL8366S_DRIVER_NAME "rtl8366s"
#define RTL8366S_PHY_NO_MAX 4
#define RTL8366S_PHY_PAGE_MAX 7
static int rtl8366s_setup(struct rtl8366_smi *smi)
{
- struct rtl8366_platform_data *pdata;
int err;
unsigned i;
-#ifdef CONFIG_OF
- struct device_node *np;
unsigned num_initvals;
const __be32 *paddr;
-#endif
-
- pdata = smi->parent->platform_data;
- if (pdata && pdata->num_initvals && pdata->initvals) {
- dev_info(smi->parent, "applying initvals\n");
- for (i = 0; i < pdata->num_initvals; i++)
- REG_WR(smi, pdata->initvals[i].reg,
- pdata->initvals[i].val);
- }
-
-#ifdef CONFIG_OF
- np = smi->parent->of_node;
+ struct device_node *np = smi->parent->of_node;
paddr = of_get_property(np, "realtek,initvals", &num_initvals);
if (paddr) {
return err;
}
}
-#endif
/* set maximum packet length to 1536 bytes */
REG_RMW(smi, RTL8366S_SGCR, RTL8366S_SGCR_MAX_LENGTH_MASK,
}
}
-#ifdef CONFIG_OF
static const struct of_device_id rtl8366s_match[] = {
{ .compatible = "realtek,rtl8366s" },
{},
};
MODULE_DEVICE_TABLE(of, rtl8366s_match);
-#endif
static struct platform_driver rtl8366s_driver = {
.driver = {
.name = RTL8366S_DRIVER_NAME,
-#ifdef CONFIG_OF
- .of_match_table = of_match_ptr(rtl8366s_match),
-#endif
+ .of_match_table = rtl8366s_match,
},
.probe = rtl8366s_probe,
.remove_new = rtl8366s_remove,
#include <linux/init.h>
#include <linux/device.h>
#include <linux/of.h>
-#include <linux/of_platform.h>
+#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/skbuff.h>
-#include <linux/rtl8367.h>
+#include "rtl8367.h"
#include "rtl8366_smi.h"
#define RTL8367_RESET_DELAY 1000 /* msecs*/
return 0;
}
-#ifdef CONFIG_OF
static int rtl8367_extif_init_of(struct rtl8366_smi *smi,
const char *name)
{
return err;
}
-#else
-static int rtl8367_extif_init_of(struct rtl8366_smi *smi,
- const char *name)
-{
- return -EINVAL;
-}
-#endif
static int rtl8367_setup(struct rtl8366_smi *smi)
{
- struct rtl8367_platform_data *pdata;
int err;
int i;
- pdata = smi->parent->platform_data;
-
err = rtl8367_init_regs(smi);
if (err)
return err;
/* initialize external interfaces */
- if (smi->parent->of_node) {
- err = rtl8367_extif_init_of(smi, "realtek,extif");
- if (err)
- return err;
- } else {
- err = rtl8367_extif_init(smi, 0, pdata->extif0_cfg);
- if (err)
- return err;
-
- err = rtl8367_extif_init(smi, 1, pdata->extif1_cfg);
- if (err)
- return err;
- }
+ err = rtl8367_extif_init_of(smi, "realtek,extif");
+ if (err)
+ return err;
/* set maximum packet length to 1536 bytes */
REG_RMW(smi, RTL8367_SWC0_REG, RTL8367_SWC0_MAX_LENGTH_MASK,
rtl8367_reset_chip(smi);
}
-#ifdef CONFIG_OF
static const struct of_device_id rtl8367_match[] = {
{ .compatible = "realtek,rtl8367" },
{},
};
MODULE_DEVICE_TABLE(of, rtl8367_match);
-#endif
static struct platform_driver rtl8367_driver = {
.driver = {
.name = RTL8367_DRIVER_NAME,
-#ifdef CONFIG_OF
- .of_match_table = of_match_ptr(rtl8367_match),
-#endif
+ .of_match_table = rtl8367_match,
},
.probe = rtl8367_probe,
.remove_new = rtl8367_remove,
--- /dev/null
+/*
+ * Realtek RTL8367 ethernet switch driver
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#ifndef _RTL8367_H
+#define _RTL8367_H
+
+#define RTL8367_DRIVER_NAME "rtl8367"
+#define RTL8367B_DRIVER_NAME "rtl8367b"
+
+enum rtl8367_port_speed {
+ RTL8367_PORT_SPEED_10 = 0,
+ RTL8367_PORT_SPEED_100,
+ RTL8367_PORT_SPEED_1000,
+};
+
+struct rtl8367_port_ability {
+ int force_mode;
+ int nway;
+ int txpause;
+ int rxpause;
+ int link;
+ int duplex;
+ enum rtl8367_port_speed speed;
+};
+
+enum rtl8367_extif_mode {
+ RTL8367_EXTIF_MODE_DISABLED = 0,
+ RTL8367_EXTIF_MODE_RGMII,
+ RTL8367_EXTIF_MODE_MII_MAC,
+ RTL8367_EXTIF_MODE_MII_PHY,
+ RTL8367_EXTIF_MODE_TMII_MAC,
+ RTL8367_EXTIF_MODE_TMII_PHY,
+ RTL8367_EXTIF_MODE_GMII,
+ RTL8367_EXTIF_MODE_RGMII_33V,
+ RTL8367B_EXTIF_MODE_RMII_MAC = 7,
+ RTL8367B_EXTIF_MODE_RMII_PHY,
+ RTL8367B_EXTIF_MODE_RGMII_33V,
+};
+
+struct rtl8367_extif_config {
+ unsigned int txdelay;
+ unsigned int rxdelay;
+ enum rtl8367_extif_mode mode;
+ struct rtl8367_port_ability ability;
+};
+
+#endif /* _RTL8367_H */
#include <linux/init.h>
#include <linux/device.h>
#include <linux/of.h>
-#include <linux/of_platform.h>
+#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/skbuff.h>
-#include <linux/rtl8367.h>
+#include "rtl8367.h"
#include "rtl8366_smi.h"
#define RTL8367B_RESET_DELAY 1000 /* msecs*/
return 0;
}
-#ifdef CONFIG_OF
static int rtl8367b_extif_init_of(struct rtl8366_smi *smi,
const char *name)
{
return err;
}
-#else
-static int rtl8367b_extif_init_of(struct rtl8366_smi *smi,
- const char *name)
-{
- return -EINVAL;
-}
-#endif
static int rtl8367b_setup(struct rtl8366_smi *smi)
{
- struct rtl8367_platform_data *pdata;
int err;
int i;
- pdata = smi->parent->platform_data;
-
err = rtl8367b_init_regs(smi);
if (err)
return err;
/* initialize external interfaces */
- if (smi->parent->of_node) {
- err = rtl8367b_extif_init_of(smi, "realtek,extif");
- if (err)
- return err;
- } else {
- err = rtl8367b_extif_init(smi, 0, pdata->extif0_cfg);
- if (err)
- return err;
-
- err = rtl8367b_extif_init(smi, 1, pdata->extif1_cfg);
- if (err)
- return err;
- }
+ err = rtl8367b_extif_init_of(smi, "realtek,extif");
+ if (err)
+ return err;
/* set maximum packet length to 1536 bytes */
REG_RMW(smi, RTL8367B_SWC0_REG, RTL8367B_SWC0_MAX_LENGTH_MASK,
rtl8367b_reset_chip(smi);
}
-#ifdef CONFIG_OF
static const struct of_device_id rtl8367b_match[] = {
{ .compatible = "realtek,rtl8367b" },
{},
};
MODULE_DEVICE_TABLE(of, rtl8367b_match);
-#endif
static struct platform_driver rtl8367b_driver = {
.driver = {
.name = RTL8367B_DRIVER_NAME,
-#ifdef CONFIG_OF
- .of_match_table = of_match_ptr(rtl8367b_match),
-#endif
+ .of_match_table = rtl8367b_match,
},
.probe = rtl8367b_probe,
.remove_new = rtl8367b_remove,
+++ /dev/null
-/*
- * Platform data definition for the Realtek RTL8366RB/S ethernet switch driver
- *
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- */
-
-#ifndef _RTL8366_H
-#define _RTL8366_H
-
-#define RTL8366_DRIVER_NAME "rtl8366"
-#define RTL8366S_DRIVER_NAME "rtl8366s"
-#define RTL8366RB_DRIVER_NAME "rtl8366rb"
-
-struct rtl8366_smi;
-
-enum rtl8366_type {
- RTL8366_TYPE_UNKNOWN,
- RTL8366_TYPE_S,
- RTL8366_TYPE_RB,
-};
-
-struct rtl8366_initval {
- unsigned reg;
- u16 val;
-};
-
-struct rtl8366_platform_data {
- unsigned gpio_sda;
- unsigned gpio_sck;
- void (*hw_reset)(struct rtl8366_smi *smi, bool active);
-
- unsigned num_initvals;
- struct rtl8366_initval *initvals;
-};
-
-enum rtl8366_type rtl8366_smi_detect(struct rtl8366_platform_data *pdata);
-
-#endif /* _RTL8366_H */
+++ /dev/null
-/*
- * Platform data definition for the Realtek RTL8367 ethernet switch driver
- *
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- */
-
-#ifndef _RTL8367_H
-#define _RTL8367_H
-
-#define RTL8367_DRIVER_NAME "rtl8367"
-#define RTL8367B_DRIVER_NAME "rtl8367b"
-
-enum rtl8367_port_speed {
- RTL8367_PORT_SPEED_10 = 0,
- RTL8367_PORT_SPEED_100,
- RTL8367_PORT_SPEED_1000,
-};
-
-struct rtl8367_port_ability {
- int force_mode;
- int nway;
- int txpause;
- int rxpause;
- int link;
- int duplex;
- enum rtl8367_port_speed speed;
-};
-
-enum rtl8367_extif_mode {
- RTL8367_EXTIF_MODE_DISABLED = 0,
- RTL8367_EXTIF_MODE_RGMII,
- RTL8367_EXTIF_MODE_MII_MAC,
- RTL8367_EXTIF_MODE_MII_PHY,
- RTL8367_EXTIF_MODE_TMII_MAC,
- RTL8367_EXTIF_MODE_TMII_PHY,
- RTL8367_EXTIF_MODE_GMII,
- RTL8367_EXTIF_MODE_RGMII_33V,
- RTL8367B_EXTIF_MODE_RMII_MAC = 7,
- RTL8367B_EXTIF_MODE_RMII_PHY,
- RTL8367B_EXTIF_MODE_RGMII_33V,
-};
-
-struct rtl8367_extif_config {
- unsigned int txdelay;
- unsigned int rxdelay;
- enum rtl8367_extif_mode mode;
- struct rtl8367_port_ability ability;
-};
-
-struct rtl8367_platform_data {
- unsigned gpio_sda;
- unsigned gpio_sck;
- void (*hw_reset)(bool active);
-
- struct rtl8367_extif_config *extif0_cfg;
- struct rtl8367_extif_config *extif1_cfg;
-};
-
-#endif /* _RTL8367_H */